<!--
  -    Copyright (c) 2018-2025, hycloud All rights reserved.
  -
  - Redistribution and use in source and binary forms, with or without
  - modification, are permitted provided that the following conditions are met:
  -
  - Redistributions of source code must retain the above copyright notice,
  - this list of conditions and the following disclaimer.
  - Redistributions in binary form must reproduce the above copyright
  - notice, this list of conditions and the following disclaimer in the
  - documentation and/or other materials provided with the distribution.
  - Neither the name of the pig4cloud.com developer nor the names of its
  - contributors may be used to endorse or promote products derived from
  - this software without specific prior written permission.
  - Author: hycloud
  -->
<template>
    <div class="execution">
        <basic-container>
             <el-row :span="24">
                <el-col
                :xs="24"
                :sm="24"
                :md="4"
                v-if="!areaId"
                class="drug__tree">
                    <avue-tree
                        :option="treeOption"
                        :data="treeData"
                        @node-click="nodeClick">
                        <span class="el-tree-node__label" slot-scope="{ node, data }">
                        <el-tooltip class="item" effect="dark" content="无数据权限" placement="right-start" v-if="data.isLock">
                            <span>{{node.label}}  <i class="el-icon-lock"></i></span>
                        </el-tooltip>
                        <span v-if="!data.isLock">{{node.label}}</span>
                        </span>
                    </avue-tree>
                </el-col>
                <el-col
                :xs="24"
                :sm="24"
                :md="areaId ? 24:20"
                class="drug__main">
                    <avue-crud ref="crud"
                            :page.sync="page"
                            :data="tableData"
                            :permission="permissionList"
                            :table-loading="tableLoading"
                            :option="tableOption"
                            @on-load="getList"
                            @search-change="searchChange"
                            @refresh-change="refreshChange"
                            @size-change="sizeChange"
                            @current-change="currentChange"
                            @row-update="handleUpdate"
                            @row-save="handleSave"
                            @row-del="rowDel">
                            <template
                                slot="categoryId"
                                slot-scope="scope">
                                {{ getFlName(scope.row.categoryId) }}
                            </template>
                            <template slot="menuLeft">
                                <el-button
                                v-if="!areaId"
                                icon="el-icon-circle-plus"
                                size="small"
                                type="primary"
                                @click="addForm()">新增</el-button>
                            </template>
                            <template slot="menu" slot-scope="scope">
                                <el-button type="text"
                                icon="el-icon-edit"
                                size="small"
                                @click="editForm(scope)">编辑</el-button>
                                <el-button type="text"
                                size="small"
                                @click="copyForm(scope)">复制</el-button>
                                <el-button type="text"
                                size="small"
                                @click="recordForm(scope)">履历</el-button>
                            </template>
                    </avue-crud>
                </el-col>
            </el-row>
        </basic-container>
        <el-dialog
            :title="title2"
            class="asset-dialog"
            v-if="dialogVisible"
            :visible.sync="dialogVisible"
            @close="closeDialog1"
            :close-on-click-modal="false"
            fullscreen>
            <div class="content">
                <el-form :model="assetData" ref="assetData" :rules="rules" label-width="100px">
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="资产类别" prop="categoryId">
                                <el-cascader
                                @change="changeCategory"
                                :options="treeData"
                                :disabled="!canEdit"
                                v-model="assetData.categoryId"
                                :props="cProps"
                                clearable></el-cascader>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="标准型号">
                                <el-select v-model="assetData.modelId"
                                        placeholder="请选择标准型号"
                                         @change="changeModel"
                                        clearable>
                                    <el-option v-for="item in optionsXh"
                                            :key="item.value"
                                            :label="item.spec"
                                            :value="item.modelId">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="资产编码" prop="no">
                                <el-input v-model="assetData.no" :maxlength="32"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="资产名称" prop="name">
                                <el-input v-model="assetData.name" :maxlength="128" :disabled="!canEdit"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="规格型号">
                                <el-input v-model="assetData.spec" :maxlength="64" :disabled="!canEdit"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="计量单位">
                                <el-input v-model="assetData.unit" :maxlength="12" :disabled="!canEdit"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="品牌">
                                <el-input v-model="assetData.brand" :disabled="!canEdit" :maxlength="64"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="sn号">
                                <el-input v-model="assetData.sn" :maxlength="64"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="购入日期" prop="buyDate">
                                <el-date-picker
                                    v-model="assetData.buyDate"
                                    type="date"
                                    placeholder="请选择购入日期"
                                    value-format="yyyy-MM-dd">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="rfid">
                                <el-input v-model="assetData.rfid" :maxlength="64"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="金额" prop="price">
                                <el-input-number v-model="assetData.price" :min="0" :max="10000000"></el-input-number>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="管理员">
                                <!-- <el-input  placeholder="请选择管理员" v-model="handleId_str"  @focus="choseMember('handleId')">
                                    <el-button slot="append" @click="choseMember('handleId')">选择</el-button>
                                </el-input> -->
                                <el-select v-model="assetData.handleId"
                                        @change="changeAdmin"
                                        placeholder="请选择管理员"
                                        clearable>
                                    <el-option v-for="item in optionsGly"
                                            :key="item.userId"
                                            :label="item.realname"
                                            :value="item.userId">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="使用人">
                                <el-input  placeholder="请选择使用人" id="user_input" v-model="useId_str">
                                    <el-button slot="append" @click="choseMember('useId')">选择</el-button>
                                </el-input>
                                <!-- <el-input v-model="assetData.useId"></el-input> -->
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="使用部门">
                                <el-input v-model="assetData.useDeptName" disabled></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="状态">
                                <el-select v-model="assetData.status"
                                        placeholder="请选择状态"
                                        disabled
                                        clearable>
                                    <el-option v-for="item in optionsZt"
                                            :key="item.id"
                                            :label="item.label"
                                            :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="使用期限(月)">
                                <el-input-number v-model="assetData.timeLimit" :min="0" :max="10000000"></el-input-number>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="区域" prop="areaId">
                                <el-cascader
                                :options="treeData1"
                                v-model="assetData.areaId"
                                :props="aProps"
                                clearable></el-cascader>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="存放地点">
                                <el-input v-model="assetData.address" :maxlength="64"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="备注">
                                <el-input v-model="assetData.remark" type="textarea"  :maxlength="240" :rows="5"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="来源">
                                <el-select v-model="assetData.source"
                                        placeholder="请选择来源"
                                        clearable>
                                    <el-option v-for="item in optionsLy"
                                            :key="item.id"
                                            :label="item.label"
                                            :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="照片">
                                <el-upload
                                    :headers="headers"
                                    :show-file-list="false"
                                    :on-success="handleAvatarSuccess"
                                    class="avatar-uploader"
                                    action="/act/file/upload"
                                    >
                                    <div class="avatar-block" v-if="assetData.cover">
                                        <img id="avatar"
                                            :src="avatarUrl"
                                            class="avatar"
                                        />
                                        <i class="el-icon-delete" @click.stop="deleteImg"></i>
                                    </div>
                                    <i v-else class="el-icon-plus avatar-uploader-icon" />
                                    </el-upload>
                                <!-- <el-input v-model="assetData.cover"></el-input> -->
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
            <div class="wbxx-block">
                <div class="block-header">
                    维保信息
                </div>
                <el-form :model="assetData" ref="assetData1" :rules="rules" label-width="100px">
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="供应商" prop="supplier">
                                <el-input v-model="assetData.supplier" :maxlength="64"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="联系人">
                                <el-input v-model="assetData.contact" :maxlength="20"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="联系方式">
                                <el-input v-model="assetData.phone" :maxlength="20"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="负责人">
                                <el-input  placeholder="请选择负责人"  id="maintenanceHandle_input" v-model="maintenanceHandleId_str">
                                    <el-button slot="append" @click="choseMember('maintenanceHandleId')">选择</el-button>
                                </el-input>
                                <!-- <el-input v-model="assetData.maintenanceHandleId"></el-input> -->
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="维保到期">
                                <el-date-picker
                                    v-model="assetData.maintenanceExpireDate"
                                    type="date"
                                    placeholder="请选择维保到期日期"
                                    value-format="yyyy-MM-dd">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="16">
                            <el-form-item label="维保说明">
                                <el-input v-model="assetData.maintenanceRemark" type="textarea"  :maxlength="256" :rows="5"></el-input>
                                <!-- <el-input v-model="assetData.maintenanceRemark"></el-input> -->
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
            <div class="fjxx-block">
                <div class="block-header">
                    附件信息
                </div>
                <div class="upload-block">
                    <el-upload
                        :key="keyNum"
                        class="upload-demo"
                        :headers="headers"
                        action="/act/file/upload"
                        :on-success="handleSuccess"
                        :on-preview="download"
                        :on-remove="handleRemove"
                        :file-list="fileList">
                        <el-button size="small" type="primary">点击上传</el-button>
                    </el-upload>
                </div>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="closeDialog1">取 消</el-button>
                <el-button type="primary" @click="alarmHandle('assetData')">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog
            :visible.sync="modal1"
            v-if="modal1"
            title="资产履历"
            width="1200px"
            top="2vh"
            :close-on-click-modal="false"
            append-to-body>
            <asset-record :assetId="assetId"></asset-record>
        </el-dialog>
        <choose-member v-if="showChose" :labelkey="labelkey" :url1="url1" :url2="url2" :title="title1" :columns1="columns1" :columns="columns" :type="type" :flKey="flKey"></choose-member>
    </div>
</template>

<script>
    import {fetchList, copy, addObj, putObj, delObj} from '@/api/asset/asset'
    import {tableOption} from '@/const/crud/asset/asset'
    import { remote } from "@/api/admin/dict";
    import { roleCodeArray } from "@/api/admin/user";
    import store from '@/store'
    import { fetchTree, fetchList as fetchList1 } from '@/api/asset/assetcategory'
    import chooseMember from '@/components/chooseMember'
    import eventBus from '@/util/eventBus'
    import assetRecord from '@/views/asset/assetrecord/index'
    import { fetchTree as fetchTree1 } from '@/api/admin/sysarea'
    import { fetchList as fetchList2 } from '@/api/asset/assetmodel'
    import {mapGetters} from 'vuex'

    export default {
        name: 'asset',
        props: ['areaId'],
        components: { chooseMember, assetRecord },
        data() {
            return {
                searchForm: {},
                tableData: [],
                defaultProps: {
                    label: 'name',
                    value: 'id'
                },
                categoryId: '',
                assetId: '',
                modal1: false,
                maintenanceHandleId_str: '',
                handleId_str: '',
                useId_str: '',
                avatarUrl: '',
                fileList: [],
                canEdit: true,
                cProps: {
                    label: 'name',
                    value: 'id',
                    emitPath:false,
                    checkStrictly: true
                },
                rules: {
                    categoryId: [
                        { required: true, message: '请选择资产类别' }
                    ],
                    no: [
                        { required: true, message: '请输入资产编码', trigger: 'blur' },
                    ],
                    name: [
                        { required: true, message: '请输入资产名称', trigger: 'blur' }
                    ],
                    supplier: [
                        { required: true, message: '请输入供应商', trigger: 'blur' }
                    ],
                    price: [
                        { required: true, message: '请输入金额', trigger: 'blur' },
                    ],
                    buyDate: [
                        { required: true, message: '请选择购入日期' }
                    ],
                    areaId: [
                        { required: true, message: '请选择区域' }
                    ]
                },
                aProps: {
                    label: 'name',
                    value: 'id',
                    emitPath:false,
                    checkStrictly: true
                },
                optionsXh: [],
                optionsLy: [],
                optionsZt: [],
                optionsGly: [],
                options: [{
                }],
                assetData: {
                    status:'0'
                },
                wbData: {},
                dialogVisible: false,
                treeOption: {
                    nodeKey: 'id',
                    addBtn: false,
                    menu: false,
                    props: {
                        label: 'name',
                        value: 'id'
                    }
                },
                flKey: '',
                url1: '',
                url2: '',
                type:'',
                columns:[],
                columns1:[],
                title1: '',
                title2: '',
                withMember_str: '',
                labelkey: '',
                showChose: false,
                editFlag: false,
                keyNum: 0,
                form: {},
                form1: {},
                flList: [],
                treeData: [],
                treeData1: [],
                page: {
                    total: 0, // 总页数
                    currentPage: 1, // 当前页数
                    pageSize: 20 // 每页显示多少条
                },
                tableLoading: false,
                tableOption: tableOption
            }
        },
        created() {
            if (this.areaId) {
                this.tableOption.menu = false
            } else {
                this.tableOption.menu = true
            }
            this.init()
            this.listenEvent()
            this.eventBusHandle()
        },
        computed: {
            ...mapGetters(['permissions']),
            headers() {
                return {
                    Authorization: "Bearer " + store.getters.access_token
                }
            },
            permissionList() {
                return {
                    addBtn: false,
                    delBtn: this.vaildData(this.permissions.act_asset_del, false),
                    editBtn: false
                };
            }
        },
        methods: {
            deleteImg() {
                this.avatarUrl = ''
                this.assetData.cover = ''
            },
            recordForm (scope) {
                this.assetId = scope.row.assetId
                this.modal1 = true
            },
            closeDialog1() {
                this.dialogVisible = false
                this.assetData = {}
            },
            download(file) {
                window.open(file.response.data.url)
            },
            copyForm(scope) {
                this.$prompt('请输入数量', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    inputPattern:/^([1-9]{1})$/,
                    inputErrorMessage: '数量范围为1-9'
                }).then(({ value }) => {
                    copy({assetId:scope.row.assetId, number: Number(value)}).then(response => {
                        this.$message.success('复制成功')
                        this.getList(this.page)
                    })
                })
            },
            alarmHandle(formName) {
                const _this = this
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                         this.$refs['assetData1'].validate((valid1) => {
                            if (valid1) {
                                if (!_this.editFlag) {
                                    addObj(_this.assetData).then(data => {
                                        _this.$message.success('添加成功')
                                        _this.closeDialog1()
                                        _this.getList(_this.page)
                                    })
                                } else {
                                    putObj(_this.assetData).then(data => {
                                        _this.$message.success('编辑成功')
                                        _this.closeDialog1()
                                        _this.getList(_this.page)
                                    })
                                }
                            }
                         })
                    }
                })
            },
            eventBusHandle () {
                let _this = this
                eventBus.$on('getMember', function (data) {
                    if (data.useId_choose_member) {
                        _this.assetData.useId = data.useId[0].userId
                        _this.assetData.useRealname = data.useId[0].realname
                        _this.assetData.useDeptName = data.useId[0].deptName
                        _this.assetData.useDeptId = data.useId[0].deptId
                        _this.useId_str = data.useId_choose_member
                    } else if (data.handleId_choose_member) {
                        _this.assetData.handleId = data.handleId[0].userId
                        _this.assetData.handleRealname = data.handleId[0].realname
                        _this.handleId_str = data.handleId_choose_member
                    } else if (data.maintenanceHandleId_choose_member) {
                        _this.assetData.maintenanceHandleId = data.maintenanceHandleId[0].userId
                        _this.assetData.maintenanceHandleRealname = data.maintenanceHandleId[0].realname
                        _this.maintenanceHandleId_str = data.maintenanceHandleId_choose_member
                    }
                })
            },
            choseMember (id) {
                this.type = "radio"
                this.labelkey = id + '_choose_member'
                this.url1 = '/admin/dept/tree'
                this.url2 = '/admin/user/page/simple'
                this.title1 = '组织机构'
                this.flKey = 'deptId'
                this.columns = [
                {
                    title: '用户名',
                    dataIndex: 'username',
                    key: 'username',
                },
                {
                    title: '姓名',
                    key: 'realname',
                    dataIndex: 'realname',
                },
                {
                    title: '所属部门',
                    dataIndex: 'deptId',
                    key:'deptId',
                    scopedSlots: { customRender: 'deptId' },
                },
                {
                    title: '岗位',
                    dataIndex: 'post',
                    key: 'post',
                    scopedSlots: { customRender: 'post' }
                }
                ]
                this.columns1 = [
                {
                    title: '用户名',
                    dataIndex: 'username',
                    key: 'username' 
                },
                {
                    title: '操作',
                    key: 'action',
                    scopedSlots: { customRender: 'action' },
                },
                ]
                this.showChose = true
            },
            changeAdmin(value) {
                let list = this.optionsGly.filter(item => {
                    return item.userId === value
                })[0]
                this.assetData.handleId = list.userId
                this.assetData.handleRealname = list.realname
            },
            init() {
                fetchTree({status: 1}).then(response => {
                    this.treeData = response.data.data
                })
                fetchList1({current: 1, size:1000}).then(response => {
                    this.flList = response.data.data.records
                })
                this.getModel()
                // 资产来源
                remote('asset_source').then(response => {
                    this.optionsLy = response.data.data
                })
                // 资产状态
                remote('asset_use_status').then(response => {
                    this.optionsZt = response.data.data
                })
                // 管理员
                roleCodeArray(['ROLE_SERVICE_ASSET_HANDEL']).then(response => {
                    this.optionsGly = response.data.data
                })
                fetchTree1().then(response => {
                    this.treeData1 = response.data.data
                })
            },
            getModel(params) {
                fetchList2(Object.assign({
                    current: 1,
                    size:1000,
                    status: '1'
                }, params)).then(response => {
                    this.optionsXh = response.data.data.records
                })
            },
            changeCategory(value) {
                this.getModel({categoryId: value})
                this.assetData.timeLimit = this.flList.filter(item => {
                    return item.categoryId === value
                })[0].timeLimit
            },
            handleAvatarSuccess(res, file, fileList) {
                this.avatarUrl = URL.createObjectURL(file.raw)
                this.assetData.cover = res.data.url
                this.keyNum += 1
            },
            handleSuccess(response, file, fileList) {
                this.assetData.attachment = JSON.stringify(fileList)
            },
            handleRemove(file, fileList) {
                this.assetData.attachment = JSON.stringify(fileList)
            },
            changeModel(value) {
                let modelForm = this.optionsXh.filter(item => {
                    return item.modelId === value
                })
                if (modelForm.length > 0) {
                    this.canEdit = false
                    this.assetData.categoryId = modelForm[0].categoryId
                    this.assetData.name = modelForm[0].name
                    this.assetData.spec = modelForm[0].spec
                    this.assetData.unit = modelForm[0].unit
                    this.assetData.price = modelForm[0].value
                    this.assetData.brand = modelForm[0].brand
                    this.assetData.cover = modelForm[0].cover
                    this.avatarUrl = modelForm[0].cover
                    this.assetData.timeLimit = this.flList.filter(item => {
                        return item.categoryId === modelForm[0].categoryId
                    })[0].timeLimit
                    // this.alarmHandle('assetData')
                } else {
                    this.assetData.categoryId = ''
                    this.assetData.name = ''
                    this.assetData.unit = ''
                    this.assetData.spec = ''
                    this.assetData.price = ''
                    this.assetData.brand = ''
                    this.assetData.cover = ''
                    this.avatarUrl = ''
                    this.assetData.timeLimit = ''
                    this.canEdit = true
                }
            },
            listenEvent() {
                let _this = this
                document.addEventListener("keydown", function (event) {
                    if (event.keyCode == 8 || event.keyCode == 46) {//backspace 或 delete键
                        if(event.target.id === 'maintenanceHandle_input') {
                            _this.maintenanceHandleId_str = ''
                            _this.assetData.maintenanceHandleId = ''
                            _this.assetData.maintenanceHandleRealname = ''
                        } else if(event.target.id === 'user_input') {
                            _this.assetData.useId = ''
                            _this.assetData.useRealname = ''
                            _this.assetData.useDeptName = ''
                            _this.useId_str = ''
                        }
                    }
                })
            },
            addForm(){
                this.title2 = '新增资产'
                this.useId_str = ''
                this.maintenanceHandleId_str = ''
                this.fileList = []
                this.editFlag = false
                this.canEdit = true
                this.dialogVisible = true
            },
            editForm(scope) {
                this.title2 = '编辑资产'
                this.editFlag = true
                if(scope.row.modelId) {
                    this.canEdit = false
                } else {
                    this.canEdit = true
                }
                this.fileList = JSON.parse(scope.row.attachment) || []
                this.assetData = Object.assign({}, scope.row)
                this.useId_str = scope.row.useRealname
                this.handleId_str = scope.row.handleRealname
                this.maintenanceHandleId_str = scope.row.maintenanceHandleRealname
                this.avatarUrl = scope.row.cover
                this.dialogVisible = true
            },
            nodeClick(data) {
                this.page.currentPage = 1
                this.categoryId = data.id
                this.getList(this.page, {categoryId: data.id})
            },
            getFlName(id) {
                let list =  this.flList.filter(item => {
                    return item.categoryId === id
                })
                return list.length > 0 ? list[0].name : ''
            },
            getType(data) {
                this.form.type = data.type
            },
            getList(page, params) {
                this.tableLoading = true
                let att = {
                    current: page.currentPage,
                    size: page.pageSize
                }
                if (this.areaId) {
                    att.areaId = this.areaId
                }
                fetchList(Object.assign(att, params, this.searchForm, {categoryId: this.categoryId} )).then(response => {
                    this.tableData = response.data.data.records
                    this.page.total = response.data.data.total
                    this.tableLoading = false
                }).catch(() => {
                    this.tableLoading=false
                })
            },
            rowDel: function (row, index) {
                this.$confirm('是否确认删除?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(function () {
                    return delObj(row.assetId)
                }).then(data => {
                    this.$message.success('删除成功')
                    this.getList(this.page)
                })
            },
            handleUpdate: function (row, index, done,loading) {
                putObj(row).then(data => {
                    this.$message.success('修改成功')
                    done()
                    this.getList(this.page)
                }).catch(() => {
                    loading();
                });
            },
            handleSave: function (row, done,loading) {
                addObj(row).then(data => {
                    this.$message.success('添加成功')
                    done()
                    this.getList(this.page)
                }).catch(() => {
                    loading();
                });
            },
            sizeChange(pageSize){
                this.page.pageSize = pageSize
            },
            currentChange(current){
                this.page.currentPage = current
            },
            searchChange(form, done) {
                this.searchForm = form
                this.page.currentPage = 1
                this.getList(this.page, form)
                done()
            },
            refreshChange() {
                this.getList(this.page)
            }
        }
    }
</script>

<style scoped lang="scss">
.asset-dialog{
    /deep/.el-dialog__body{
        height: 80vh;
        overflow: auto;
    }
    .el-cascader, .el-select, .el-input-number, .el-date-editor {
        width: 100%;
    }
    .block-header{
        font-size: 18px;
        color: #222;
        font-weight: bold;
        margin-bottom: 10px;
    }
    /deep/.avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }

    /deep/.avatar-uploader .el-upload:hover {
        border-color: #409eff;
    }

    /deep/.avatar-uploader-icon {
        font-size: 28px !important;
        color: #8c939d !important;
        width: 178px !important;
        height: 178px !important;
        line-height: 178px !important;
        text-align: center !important;
    }

    /deep/.avatar-block {
        width: 178px;
        height: 178px;
        display: block;
        position: relative;
        .el-icon-delete{
            display: none;
            position: absolute;
            font-size: 18px;
            top: 85px;
            left: 85px;
            color: #111;
        }
        img{
            width: 100%;
            height: 100%;
        }
        &:hover{
            .el-icon-delete{
                display: inline-block;
            }
        }
    }
}
</style>